package com.menu.Controller;

import com.menu.Service.CollectionService;
import com.menu.Utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "收藏接口")
@RestController
public class CollectionController {

    @Resource
    CollectionService collectionService;


    @ApiOperation(value = "收藏功能")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "userId", value = "用户id", required = true),
                    @ApiImplicitParam(name = "menuId", value = "食谱id或菜单id", required = true),
                    @ApiImplicitParam(name = "menuType", value = "收藏类型0代表食谱,1代表菜单", required = true)
            }
    )
    @PostMapping("/User/collection")
    public ResponseResult collection(Integer userId, Integer menuId,Integer menuType){
        return collectionService.collection(userId, menuId,menuType);
    }



    @ApiOperation(value = "判断是否收藏")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "userId", value = "用户id", required = true),
                    @ApiImplicitParam(name = "menuId", value = "食谱id", required = true),
                    @ApiImplicitParam(name = "menuType", value = "0是食谱,1是菜单", required = true)
            }
    )
    @PostMapping("/User/judgeOfCollection")
    public ResponseResult judgeOfCollection(Integer userId, Integer menuId,Integer menuType){
        return collectionService.judgeOfCollection(userId, menuId,menuType);
    }



    @ApiOperation(value = "遍历某用户的收藏列表")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "userId", value = "用户id", required = true),
                    @ApiImplicitParam(name = "menuType", value = "0是食谱,1是菜单", required = true)
            }
    )
    @GetMapping("/Visitor/findCollectionByUserId")
    public ResponseResult findCollectionByUserId(Integer userId,Integer menuType,Integer pageNow,Integer pageSize){
        return collectionService.findCollectionByUserId(userId,menuType,pageNow,pageSize);
    }
}
